function Tests = modelDiffsrfTest()
Tests = functiontests(localfunctions);
end
%#ok<*DEFNU>




function setupOnce(This)
m = model('3eq.model','linear=',true);
m = solve(m);
m = sstate(m);
This.TestData.Model = m;
This.TestData.Tol = 1e-9;
end




function testDiffsrfShk(This)
m = This.TestData.Model;
tol = This.TestData.Tol;
eList = get(m,'eList');

exp1 = diffsrf(m,1:20,'alp4,alp3','select=',eList{1});
exp2 = diffsrf(m,1:20,'alp4,alp3','select=',eList{2});
s12 = diffsrf(m,1:20,'alp4,alp3','select=',eList([1,2]));
act1 = dbcol(s12,1);
act2 = dbcol(s12,2);

list = fieldnames(exp1);
for i = 1 : length(list)
    name = list{i};
    assertEqual(This,act1.(name)(:),exp1.(name)(:),'AbsTol',tol);
    assertEqual(This,act2.(name)(:),exp2.(name)(:),'AbsTol',tol);
end
end




function testDiffsrfPar(This)
m = This.TestData.Model;
tol = This.TestData.Tol;
eList = get(m,'eList');

exp1 = diffsrf(m,1:20,'alp4','select=',eList);
exp2 = diffsrf(m,1:20,'alp3','select=',eList);
s12 = diffsrf(m,1:20,'alp4,alp3','select=',eList);
act1 = dbpage(s12,1);
act2 = dbpage(s12,2);

list = fieldnames(exp1);
for i = 1 : length(list)
    name = list{i};
    assertEqual(This,act1.(name)(:),exp1.(name)(:),'AbsTol',tol);
    assertEqual(This,act2.(name)(:),exp2.(name)(:),'AbsTol',tol);
end
end % testDiffsrf()
